package com.fg.pro.ai.AiController;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import com.fg.pro.ai.utils.MoreAiOptions;
import com.fg.pro.model.reponse.ResponseResult;
import com.fg.pro.model.utils.UserIdThread;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@Tag(name = "aiPlatforms", description = "ai_aiPlatforms")
@RestController
@RequestMapping("aiPlatforms")
public class AiPlatformsController {

//    HashMap<String, ChatModel> model = new HashMap<>();

    @Autowired
    MoreAiOptions moreAiOptions;

    @Operation(summary = "默认回答", description = "")
    @GetMapping("/chart")
    public ResponseResult chartByBlock(@RequestParam(required = false) String question, MoreAiOptions moreAiOptions) {

        String platform = moreAiOptions.getPlatform();
        ChatModel chatModel = moreAiOptions.getModels().get(platform);

        ChatClient chatClient = ChatClient.builder(chatModel).defaultOptions(
                ChatOptions.builder()
                        .temperature(moreAiOptions.getTemperature())
                        .model(moreAiOptions.getModel())
                        .build()
        ).build();

        String content = chatClient.prompt().user(question).call().content();

        return ResponseResult.okResult(content);
    }




}
